package com.nopay.dxdwphone.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.widget.ListView;

import androidx.annotation.NonNull;

import com.nopay.dxdwphone.R;
import com.nopay.dxdwphone.ui.adapter.CallDelaySettingAdapter;

/**
 * 联系客服
 */
public class DialogCallDelaySetting extends Dialog {

    private Activity mActivity;

    public DialogCallDelaySetting(@NonNull Activity context) {
        super(context, R.style.MyDialog);
        mActivity = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_contact_customer);
        setCanceledOnTouchOutside(true);

        ListView lv_delay = findViewById(R.id.lv_customer);
        CallDelaySettingAdapter adapter = new CallDelaySettingAdapter(mActivity);
        lv_delay.setAdapter(adapter);
        lv_delay.setOnItemClickListener((parent, view, position, id) -> {
            dismiss();
            if(onSelectedItemListener != null) onSelectedItemListener.onSelectedItem(adapter.getItem(position));
        });
    }

    private OnSelectedItemListener onSelectedItemListener;

    public DialogCallDelaySetting setOnSelectedItemListener(OnSelectedItemListener onSelectedItemListener) {
        this.onSelectedItemListener = onSelectedItemListener;
        return this;
    }

    public interface OnSelectedItemListener {

        void onSelectedItem(int delay);
    }
}



